<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets">


    <ui:composition template="../../resources/template/indexTemplate.xhtml">

        <ui:define name="ẗitle">-= Associacao - Lista de Usuários =-</ui:define>
        <ui:define name="content" >

            <p:panel header="Lista de Associados" styleClass="content">
                <!--                 <h:form id="formLocalLista" onreset="{associadoController.atualizaListaAssociadosTable()}"> -->
                <h:form id="formLocalLista" prependId="false">
                    <p:growl id="messages" />
                    <p:commandButton value="Inserir Novo Associado" 
                                     ajax="false" 
                                     action="#{associadoMB.prepararAdicionar}"
                                     id="botaoPrepararAdicionar"/>

                    <p:dataTable  id="tabelaLocalLista" widgetVar="tabela" var="entity" 
                                  value="#{associadoMB.allAssociados}" 
                                  emptyMessage="Não há associados cadastrados." 
                                  paginator="true" rows="10">

                        <f:facet name="header">  
                            <p:outputPanel>  
                                <h:outputText value="Buscar em todos os campos:" />  
                                <p:inputText id="globalFilter" onkeyup="tabela.filter()" style="width:150px" />  
                            </p:outputPanel>  
                        </f:facet>  

                        <p:column 
                            headerText="Nome"
                            sortBy="#{entity.nome}"
                            filterBy="#{entity.nome}" 
                            filterStyle="display:none"
                            >
                            <h:outputText value="#{entity.nome}" />          
                        </p:column>

                        <p:column 
                            headerText="Data de Nascimento" 
                            sortBy="#{entity.nascimento}"
                            filterBy="#{entity.nascimento}"
                            filterStyle="display:none">
                            <h:outputText value="#{entity.nascimento}"  />          
                        </p:column>

                        <p:column style="width:110px">
                            <p:commandButton id="botaoVer" image="ui-icon ui-icon-bullet" title="Ver" action="#{associadoMB.prepararVisualizar(entity.id)}" ajax="false"/>
                            <p:commandButton id="botaoEditar" image="ui-icon ui-icon-pencil" title="Edit" action="#{associadoMB.prepararAlterar(entity.id)}" ajax="false"/>
                            <p:commandButton id="botaoDeletar" image="ui-icon ui-icon-close" title="Delete" actionListener="#{associadoMB.prepararRemover(entity.id)}" oncomplete="dialogConfirmacao.show()"/>
                        </p:column>  
                    </p:dataTable>


                    <p:dialog id="confirmDialog" 
                              header="Confirmar" 
                              widgetVar="dialogConfirmacao" > 
                        <h:outputText value="Você tem certeza que deseja excluir?"/> 
                        <h:panelGrid columns="2">
                            <p:commandButton id="botaoConfirmar" value="Sim"  action="#{associadoMB.delete()}" ajax="false" onclick="dialogConfirmacao.hide()" />  
                            <p:commandButton id="botaoCancelar" value="Não" onclick="dialogConfirmacao.hide()" type="button" />  
                        </h:panelGrid>
                    </p:dialog>

                </h:form>

            </p:panel>      
        </ui:define>

    </ui:composition>
</html>

